Finalized spatial function implementations. Also made some API changes, which lead to some unit test additions. Also fixed some minor issues.