Various improvements, cleared main file