General housekeeping and code cleaning