Fixed some sink processing and the main diagnostics routine. Tested on some sample data and passed.