Restructuring (Old version)

Restructured beginning of (old) code