New class Writer and some optimization