Prevent division by 0
Updated templates