Refactored some of the molecule release code.

Broke up a large function used for molecule release into three smaller
functions. Renamed some variables to be consistent with some recent
naming changes.
Bugfix: Error when using the DEBUG macro.