Simplified variable allocation

Joined #9 and #12 to one patch.