Finished mapping out logic functions; still buggy