Bug fix, code cleaning