Fixed small bugs and errors