Some refactors, added some logging