Much testing added and cleaned up