Refactor, simplify and remove unused files