More debugging and some fixes