Increased functionality and cleaned up code