Added profile array, fixed closing bug