Much faster implementation of 005.
Adding #9. Not complete yet.