Fixed a few bugs and added a debug menu