Fixed bugs

Fixed some basic bugs and some other stuff.