Improvements. Fixed several bugs