ported majority of code; will start testing now