Added missing files.

Also fixed some bugs.