Fixed bug in init, cleaned up open/close, r/w while adding sync. Need to improve sync and make it more robust