added speed optimizations
fixed typo and added missing files