Major redesign. Finished first implementation. Not tested.