Added ionic support and cleaned up code