Bug fix + code cleaning