Cleaning up of code and more improvements.