bug fixes, added 'self' for external calls