Refactored to resolve conflicts. Final.

Compiled and executes.