work on debug and profiling options
minor speed optimizations