updates and code cleaning