Optimizations; created additional helper tools