Improved rewrite implementation
Functionality of formatting buttons still needs to be adjusted to work
in rewrites