- massive cleanup and code re-organization