Fixed the problems with the friction calculations. Now works nicely.