Fix multiple issues.

 - prepare for source distribution.
 - move main function into __init__.py.
 - fix adapter change working directory issue.
 - fix import domain problem.