Refactor experimental code.

Not in working state yet. Need to test.