bin: moving all programming logic out of bin/
fix reference errors;
remove console.log; fix dependencies in package.json