Fixed and cleaned up code and interface