Replaced print statements with log entries and added some docstrings