major code clean up