Added test, optimized some code.