Cleaned up old code.
Fixed input bug and some crashes.