add exit status in tpl, print output if migration binary failed to run
refactor function signatures
rearrange functions for readability
Merge pull request #42 from ZhengYang/master

Code refactor and error fixing