Working edition. Code still needs to be cleaned up and edited.