Refactor

Moved code around.