Cleaned up a bit

Moved some long code parts into separate methods
Revert "Cleaned up a bit"

This reverts commit 1458b22214c57f65c8f6db880d57d28e761255b0.