Format some code, fix missing indexes and other stuff