Fixed a bug in the after-change function. Added some TODOs and comments.