Improved debugability, fixed potential bug