added some more comments and now pushes thread ids onto the stack for reuse in the right place
more comments
some minor formatting and adding some more comments