Added support for keyboard input.
Added debug mode.
Fixed some serious issues.