cleaned up logging a little, also made sure entire clean_up routine called in the END block