Major refactor and file re-organization