prettyfied a lot of code and implemented some new stuff