Moved some code around for second machine block