Added ability to specify arguments. Fixed race condition.