Works! Needs optimizations and beautifications.