Adding code for slow logging - untested
Code cleanup and indentation
Code cleanup and indentation
Code cleanup and indentation