Big submission.

Added files, made many code improvements.