Fixes #574, introduces keepAmdefine for edge cases that may need it
snapshot