Move some code around, to organize it in few logical blocks