code cleaning + fixes