Hopefully fixed the bugs