Bugfixes, code cleaning.