Fixed some annoying bugs and did some refactoring