Fix bugs and add exec functionality