Fixed small bugs in the code

Fixed a few small bugs