Made sure that plugins are released in the reverse order of how they are added

Fixed some defines.