Be tolerant of missing metadata

- Fixes #9
- Some code refactoring

Signed-off-by: Mansour <mansour@oxplot.com>