Add some sanity/length checks for internal data
Merge branch 'develop'