Implemented basic Action/Command infrastructure.

Many refactorings throughout.