Clean up of unused code and functions