Added optional $base_uri argument, removed ending ?>, whitespace fixes