Further refactor of code; remove unused files.