Declare variables when they are used.
Use const in interfaces where appropriate.
Cleaning up C interfaces.

No need to pass mesh dimension as separate parameter.