Fixed many small bugs and implemented a few minor but very important
missing features.