SOme small bugs found + fixed (multiple declaration of vars, and typo)