some formatting changes, add a bunch of logging to make debugging way easier.