Some general improvements. Added settings functionality.