Large code refactorization, be careful with following pulls and merges