added functions, some comments. Functions aren't yet used.