add resource locks

closes #1