Added module locks and with-module-lock macro
Added threading for commands