Some fixes and optimizations;
Write handler implemented.