Added proper out-of-memory handling and removed that WAF madness

This build system is so bad, it even contains pre-compiled binary
embedded in a python script.

This commit also introduces termbox into the wonders of realloc.