Got rid of the segfault, minor improvements and keyboard bug.