fixed serious bug! and performance improvements.