Lots of bug fixes, performance improvements and additions