separated some functions into commands.js and added comments to other functions.