Small refactoring

This commit includes some small refactoring, like
reordering methods, warning fixes and
methods / variables renaming.