request error handling + fix some missing var + cleanup ldpm/index.js