first major code changes from original version