Added some logging, comments and TODOs.