Random refactoring & optimizing