Fixed bug in is_pointer, cleaned up code