add 404 500 support; modify template head