cleaned up a lot of code, and fixed bugs

  - program closes after window closes