Implemented logging for most of relevant stuff.