small bugfix and a bit code cleaning