Somewhat working and cleaned up