Lots of improvements and bug fixing

Nice improvements!