Some code cleanup
Added more configuration options