add cors support and do a small bit of cleaning up