Moved options and api out of controller function.

Memory still grows over time.