Added some new functions that don't work yet.
Deleted unused functions.
Some final fixes.