Fixed compile errors and further implemented validation