Better memory management

Implemented the variable B_DEBUG which, if set to FALSE, cleans up
variable when they are no longer needed