Refactored (renamed, moved, deleted) code so that it is cleaner