Removed unused code
Fixed some errors