Framework for AMP, some bug fixes