Added assertions to avoid typehint fatal errors

Added comments