Overall code structure improvements