Minor improvements and code style

Retrieving the prev/next element of an enum can be done without a loop.

I hope you don't mind the additional code style changes.