New template and some bug fixes