Refactor and split into individual class files