Devscript refactor

comments, sanity-checks, bugfixes