Replace header with json response, general cleanup