added support for options
minor internal fixes