General code cleanup and added done method