Added simple logging facility, replaced prints to stderr with logger calls