closes #511 and closes #504