Various fixes/improvements.

Hi,

This is various fixes and improvements and initial packagization (setup.py).