Minor improvements

No feature added, just grouped blocks of code together when relevant