Cleaning up the code

Merged from slick666