Fix for #619. Conditonal compilation / runtime perf optimization

Adds both conditional compilation (for development in MonoDevelop / XS) and runtime checks for performance optimization.