Added permissions template & several small fixes