Constrained Hamiltonian Systems and Gauge Theories