Revert "remove a lot of unused stuff and made the code cleaner"

This reverts commit bd6666b32ea54924bd89f883763ed73e652aed53.