Rewrite based on native rearrangement support

Fixed #11. Fixed #7. Fixed #10.
Bumping up version up to 0.4.0