Fixed debug output, added basic logging