Some optimizations here and there

Nothing extraordinary. Reduction of codes, a bit of renaming. Not
mandatory to merge. But it helped me to get through the code. :)