Reorganized: better separated code based on functionality.