Improved code generation.
Fixed up example so it actually runs.
Added another convenience function to remove the need to set Password.