Fixed small bug and added more init code