Added custom listener, fixed various bits.