Implemented Flemmings update with my smaller changes.