Integrated Stephan's code.

Still some issues with resource reserving