new draft of code

I tried to broaden the code and make procedures clear. I imagine that there might be more principles to put in, but I hope this is a good start.