Initial commit. The main stuff. Additional parameter checking and validation needed.