ast: Fix memory leak in polygon

Could also sometimes cause a segfault
ast: Include header files explicitly