fixed build and cleaned up code