Bug fixes

Fixed all the bugs that were initially there.