Started refactoring
Completed refactor #1
COmpleted refactoring #2 + added more element types