Revert "Big code cleanup"

This reverts commit 0987a86a7e39e95b8c031e2b698c746f612030cd.