changed most code for the restructure, few problems still persist