Moved program components into separate modules
Fixed various bugs