Initial implementations. Need tests. Wrong order, I know.
Error checking is better now.
Changed names and added helper methods.