Some upgrades in code.

Works good enough.