Some fixes. Implement close. Comply to new flash api.