Commented and cleaned up main