improve error messages and add Segments module