MASSIVE code refactoring to make a generic veresion of hidra_interface.c