Fix stupid
Minor refactoring & optimizations