Final commit here before merge. Most of poll functionality implemented. Still edge cases and memory leaks.