Finish porting of the poc code. 

Things generally work now, but needs more polishing. Way too many
allocations and general messyness.