Minor changes and clean up code