better logging system + fix a couple of tiny bugs