Created permissions API. Replaced badly written space-searching for something nicer.