Bugfix

Also, fixed function prototypes.