Minor code organization
Minor updates
Fixed merge conflicts.