Some bug fixes + documentation